<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户详情</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="http://cdn.viptool.cn/lib/morris.js/0.4.3/morris.css" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="../../resource/lib/imageview/css/imageviewer.css" rel="stylesheet"/>
    <script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
    <script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
            th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316(123123)}"></script>
    <script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"></script>
    <style>
        .user-close-config {
            height: 40px;
            line-height: 40px;
        }

        .user-close-config .control-label {
            margin-left: 20px;
            font-weight: normal !important;
        }

        .user-close-config label.off {
            background-color: red;
            color: #fff;
            margin-right: 10px;
        }

        .user-close-config label.on {
            background-color: #fff;
            color: #674646;
            border: 1px solid #ccc;
            margin-right: 10px;
        }

        .separator {
            margin: 31px 20px 10px 20px;
            border-bottom: 1px solid #ccc;
        }
    </style>
</head>

<body>

<div class="wrapper wrapper-content tooltip-demo">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="ibox-title"
                     style="vertical-align: bottom;height: 100%;padding-left: 0;">
                    <div style="width: 100%;margin-top: -6px;">
                        <h3 th:text="${area.title}">剑南的直播间</h3>
                        <p style="height: 51px;" th:text="${area.desc}">
                            非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间非常优秀的直播间</p>
                        <p>创建时间：<span th:text="${#temporals.format(area.createTime,'yyyy-MM-dd HH:mm:ss')}"></span></p>
                    </div>
                </div>
                <div class="tabs-container" style="margin-top: 20px;">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#">商品</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body">
                                <div>
                                    <form id="searchForm" style="clear: both">
                                        <div class="form-inline" style="padding-bottom: 15px;float: right">
                                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                                            <input type="hidden" th:value="${condition.areaId}" name="areaId"/>
                                            <input type="text" class="form-control input-sm mb10" id="productKey"
                                                   th:value="${condition.productKey}"
                                                   name="productKey" placeholder="商品名称" style="width: 156px;"/>

                                            <button type="button"
                                                    onclick="areaHandler.search(1)"
                                                    class="btn btn-primary btn-sm m-b-none">搜索
                                            </button>
                                            <button type="button" onclick="areaHandler.searchAll()"
                                                    class="btn btn-primary btn-sm m-b-none">显示全部
                                            </button>
                                        </div>
                                    </form>
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover table-center">
                                            <thead>
                                            <tr>
                                                <th>商品</th>
                                                <th>价格</th>
                                                <th>尺寸</th>
                                                <th>库存</th>
                                                <th>排序</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <tr th:each="product:${products}">
                                            <td style="text-align: left">
                                                <img style="width: 50px;height: 50px;"
                                                     th:src="${product.productPO.mainPic}"
                                                     src="../../resource/img/p1.jpg">
                                                <span th:text="${product.productPO.productName}">这是一个商品</span>
                                            </td>
                                            <td>￥<span th:text="${product.productPO.price}">100.00</span></td>
                                            <td th:text="${product.productPO.propSize}">78*76*762</td>
                                            <td th:text="${product.productPO.availableStore()}">15</td>
                                            <td>
                                                <input type="text" class="form-control input-sm"
                                                       th:onchange="areaHandler.changeOrder([[${product.id}]],this)"
                                                       onchange="areaHandler.changeOrder(1,this)"
                                                       th:value="${product.orderWeight}" style="width: 100px;"
                                                       placeholder="排序"/>
                                            </td>
                                            <td>
                                                <a href="javascript:areaHandler.remove(1)"
                                                   th:href="|javascript:areaHandler.remove(${product.id})|">移除</a>
                                            </td>
                                        </tr>
                                        </tbody>
                                        </table>
                                    </div>
                                    <p style="float: left; margin: 20px 0;">
                                        共<span th:text="${totalRecords}"></span>条记录，当前第<span
                                            th:text="${pageIndex}"></span>/<span
                                            th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                    </p>
                                    <ul style="float: right;" class="pagination pagination-split">
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js?20190316(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js?20190316"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script src="../../resource/lib/imageview/js/imageviewer.min.js"
        th:src="@{/resource/lib/imageview/js/imageviewer.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/specialArea/products}]]*/  "";
    const apiUri = /*[[@{/specialArea}]]*/  "";
</script>
<script type="text/javascript">
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            areaHandler.search(p);
        });
    });

    var areaHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri + "?areaId=" + $("input[name=areaId]").val();
        },
        changeOrder: function (id, obj) {
            let orderWeight = $(obj).val();
            hot.ajax(apiUri + "/products/changeOrder", {
                id: id,
                orderWeight: orderWeight
            }, function (apiResult) {
                window.location.reload();
            }, function () {
            }, "post");
        },
        remove: function (id) {
            hot.confirm("确定移除该商品", function () {
                hot.ajax(apiUri + "/products/remove", {
                    id: id
                }, function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        hot.tip.success("移除成功", function () {
                            window.location.reload();
                        });
                    } else {
                        hot.tip.error("移除失败--" + apiResult.resultMsg);
                    }
                }, function () {
                }, "post");
            })
        }
    }
</script>
</body>

</html>